cc.Class({
    extends: cc.Component,
    properties: {
        coinPrefab: cc.Prefab,

    },

    onLoad() {
    },

    bet(info) {
        let coin = cc.instantiate(this.coinPrefab)
        coin.scale = 0.72
        let width = this.node.width
        let height = this.node.height

        let posX = Math.random() * width - width / 2
        let posY = Math.random() * height - height / 2
        coin.setPosition(posX, posY, 0)
        this.node.addChild(coin)
        let animation = coin.getComponent(cc.Animation)
        animation.play()
    },

    clear() {
        let coins = this.node.getChildren()
        for (let coin of coins) {
            let action = cc.removeSelf(true)
            coin.runAction(action)
        }
    },
})